import gymnasium as gym
import time

# Create the environment with human rendering
env = gym.make("Blackjack-v1", render_mode="human")
observation, info = env.reset()

# Play 10 episodes
for episode in range(10):
    observation, info = env.reset()
    done = False
    
    while not done:
        # Render the current state
        env.render()
        
        # Take a random action (0: stick, 1: hit)
        action = env.action_space.sample()
        
        # Execute the action
        observation, reward, terminated, truncated, info = env.step(action)
        done = terminated or truncated
        
        # Add a small delay to make it easier to follow
        time.sleep(1)
    
    print(f"Episode {episode + 1} finished with reward: {reward}")
    time.sleep(2)  # Pause between episodes

env.close() 